home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Freelog 121
/
FreelogMagazineJuilletAout2014-No121.iso
/
Outils
/
Adobe-Air
/
adobe-air_13.exe
/
[0]
/
setup.swf
/
scripts
/
mx
/
accessibility
/
UIComponentAccImpl.as
< prev
Wrap
Text File
|
2014-03-27
|
7KB
|
214 lines
package mx.accessibility
{
import flash.accessibility.Accessibility;
import flash.accessibility.AccessibilityProperties;
import flash.display.DisplayObjectContainer;
import flash.events.Event;
import mx.containers.Form;
import mx.containers.FormHeading;
import mx.containers.FormItem;
import mx.controls.FormItemLabel;
import mx.controls.Label;
import mx.controls.scrollClasses.ScrollBar;
import mx.core.Application;
import mx.core.Container;
import mx.core.UIComponent;
import mx.core.mx_internal;
use namespace mx_internal;
public class UIComponentAccImpl extends AccessibilityProperties
{
private static var accessibilityHooked:Boolean = hookAccessibility();
mx_internal static const VERSION:String = "3.0.0.0";
protected var master:UIComponent;
private var oldErrorString:String;
private var oldToolTip:String;
public function UIComponentAccImpl(param1:UIComponent)
{
var _loc2_:String = null;
super();
master = param1;
if(param1.accessibilityProperties)
{
silent = param1.accessibilityProperties.silent;
forceSimple = param1.accessibilityProperties.forceSimple;
noAutoLabeling = param1.accessibilityProperties.noAutoLabeling;
if(param1.accessibilityProperties.name)
{
name = param1.accessibilityProperties.name;
}
if(param1.accessibilityProperties.description)
{
description = param1.accessibilityProperties.description;
}
if(param1.accessibilityProperties.shortcut)
{
shortcut = param1.accessibilityProperties.shortcut;
}
}
if(master is ScrollBar)
{
silent = true;
}
else if(master is FormItemLabel)
{
name = getFormName(master);
silent = true;
}
else
{
_loc2_ = getFormName(master);
if(_loc2_ && _loc2_.length != 0)
{
name = _loc2_ + name;
}
if(master.toolTip && master.toolTip.length != 0)
{
oldToolTip = " " + master.toolTip;
name += oldToolTip;
}
if(master.errorString && master.errorString.length != 0)
{
oldErrorString = " " + master.errorString;
name += oldErrorString;
}
master.addEventListener("toolTipChanged",eventHandler);
master.addEventListener("errorStringChanged",eventHandler);
}
}
private static function updateFormItemString(param1:FormItem) : String
{
var _loc3_:Label = null;
var _loc6_:int = 0;
var _loc7_:int = 0;
var _loc8_:UIComponent = null;
var _loc2_:* = "";
_loc3_ = param1.itemLabel;
var _loc4_:AccessibilityProperties;
if((_loc4_ = !!_loc3_ ? _loc3_.accessibilityProperties : null) && _loc4_.silent)
{
return _loc4_.name;
}
var _loc5_:UIComponent;
if((_loc5_ = UIComponent(param1.parent)) is Form)
{
_loc7_ = _loc6_ = _loc5_.getChildIndex(param1);
while(_loc7_ >= 0)
{
if((_loc8_ = UIComponent(_loc5_.getChildAt(_loc7_))) is FormHeading)
{
_loc2_ = FormHeading(_loc8_).label + " ";
break;
}
_loc7_--;
}
}
if(param1.required)
{
_loc2_ += "Required Field ";
}
if(param1.label != "")
{
_loc2_ += param1.label + " ";
}
if(_loc4_ && !_loc4_.silent)
{
_loc4_.silent = true;
_loc4_.name = _loc2_;
}
return _loc2_;
}
mx_internal static function createAccessibilityImplementation(param1:UIComponent) : void
{
param1.accessibilityProperties = new UIComponentAccImpl(param1);
}
public static function getFormName(param1:UIComponent) : String
{
var _loc2_:String = "";
if(param1 is Container)
{
return _loc2_;
}
var _loc3_:DisplayObjectContainer = param1.parent;
while(_loc3_ && !(_loc3_ is FormItem) && !(_loc3_ is Application) && _loc3_ != param1.root)
{
_loc3_ = _loc3_.parent;
}
if(_loc3_ && _loc3_ is FormItem)
{
_loc2_ = updateFormItemString(FormItem(_loc3_));
}
return _loc2_;
}
public static function enableAccessibility() : void
{
}
private static function hookAccessibility() : Boolean
{
UIComponent.createAccessibilityImplementation = mx_internal::createAccessibilityImplementation;
return true;
}
protected function eventHandler(param1:Event) : void
{
var _loc2_:int = 0;
switch(param1.type)
{
case "errorStringChanged":
if(name && name.length != 0 && oldErrorString)
{
_loc2_ = name.indexOf(oldErrorString);
if(_loc2_ != -1)
{
name = name.substring(0,_loc2_) + name.substring(_loc2_ + oldErrorString.length);
}
oldErrorString = null;
}
if(master.errorString && master.errorString.length != 0)
{
if(!name)
{
name = "";
}
oldErrorString = " " + master.errorString;
name += oldErrorString;
}
Accessibility.updateProperties();
case "toolTipChanged":
if(name && name.length != 0 && oldToolTip)
{
_loc2_ = name.indexOf(oldToolTip);
if(_loc2_ != -1)
{
name = name.substring(0,_loc2_) + name.substring(_loc2_ + oldToolTip.length);
}
oldToolTip = null;
}
if(master.toolTip && master.toolTip.length != 0)
{
if(!name)
{
name = "";
}
oldToolTip = " " + master.toolTip;
name += oldToolTip;
}
Accessibility.updateProperties();
}
}
}
}